import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    city: '北京',
    name: '北京天安门',
    login: true
  },
  mutations: {
    change(state,city){
      state.city = city
    },
    weekD(state, weekDetail){
      state.imgUrl = weekDetail.imgUrl;
      state.name = weekDetail.name;
      state.desc = weekDetail.desc;
      state.address = weekDetail.address;
      state.mark = weekDetail.mark;
      state.rank = weekDetail.rank;
      state.data = weekDetail.data;
      state.remark = weekDetail.remark;
      state.line = weekDetail.line;
      state.title = weekDetail.title;
    },
    guessD(state, guessDetail) {
      state.imgUrl = guessDetail.imgUrl;
      state.name = guessDetail.name;
      state.desc = guessDetail.desc;
      state.address = guessDetail.address;
      state.mark = guessDetail.mark;
      state.rank = guessDetail.rank;
      state.data = guessDetail.data;
      state.remark = guessDetail.remark;
      state.line = guessDetail.line;
      state.title = guessDetail.title;
    },
    homeR(state, homeRecom) {
      state.imgUrl = homeRecom.imgUrl;
      state.name = homeRecom.name;
      state.desc = homeRecom.desc;
      state.address = homeRecom.address;
      state.mark = homeRecom.mark;
      state.rank = homeRecom.rank;
      state.data = homeRecom.data;
      state.remark = homeRecom.remark;
      state.line = homeRecom.line;
      state.title = homeRecom.title;
    }
  },
  actions: {
    change(ctx,city){
      ctx.commit('change',city)
    },
    weekD(week,weekDetail){
      week.commit('weekD',weekDetail)
    },
    guessD(guess, guessDetail) {
      guess.commit("guessD",guessDetail)
    },
    homeR(home, homeRecom) {
      home.commit("homeR", homeRecom)
    }
  },
  modules: {

  },
  plugins: [createPersistedState()]
})
